home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / htmlfont.h.z / htmlfont.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  3.4 KB  |  135 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Martin Jones (mjones@kde.org)
  3.               (C) 1997 Torben Weis (weis@kde.org)
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.     Boston, MA 02111-1307, USA.
  19. */
  20. //-----------------------------------------------------------------------------
  21. //
  22. // KDE HTML Widget
  23. //
  24.  
  25. #ifndef __HTMLFONT_H__
  26. #define __HTMLFONT_H__
  27.  
  28. #include <qlist.h>
  29. #include <qcolor.h>
  30. #include <qfont.h>
  31. #include <kcharsets.h>
  32.  
  33. #define MAXFONTSIZES 7
  34.  
  35. class HTMLFont
  36. {
  37. public:
  38.     HTMLFont( const char *_family, int _size, int _weight=QFont::Normal, bool _italic=FALSE, const char *charset=0 );
  39.     HTMLFont( const HTMLFont &f );
  40.  
  41.     void setWeight( int w )
  42.         {    font.setWeight( w ); }
  43.     void setItalic( bool u )
  44.         {    font.setItalic( u ); }
  45.     void setUnderline( bool u )
  46.         {    font.setUnderline( u ); }
  47.     void setStrikeOut( bool s )
  48.         {    font.setStrikeOut( s ); }
  49.     void setTextColor( const QColor &col )
  50.         {    textCol = col; }
  51.     void setCharset( KCharset ch )
  52.         {     chset=ch; chset.setQFont(font);}
  53.  
  54.     const char *family() const
  55.         {    return font.family(); }
  56.     const int  weight() const
  57.         {    return font.weight(); }
  58.     const bool italic() const
  59.         {    return font.italic(); }
  60.     const bool underline() const
  61.         {    return font.underline(); }
  62.     const bool strikeOut() const
  63.         {    return font.strikeOut(); }
  64.     const int  pointSize() const
  65.         {    return font.pointSize(); }
  66.     const QColor &textColor() const
  67.         {    return textCol; }
  68.     int size() const
  69.         {    return fsize; }
  70.     const KCharset charset () const
  71.             {    return chset; }
  72.  
  73.     const HTMLFont &operator=( const HTMLFont &f );
  74.     bool operator==( const HTMLFont &f );
  75.     operator QFont() const
  76.         {    return font; }
  77.  
  78.     static int pointSize( int _size );
  79.  
  80. private:
  81.     QFont  font;
  82.     QColor textCol;
  83.     KCharset chset;
  84.     int    fsize;
  85. };
  86.  
  87. inline HTMLFont::HTMLFont( const HTMLFont &f ) : font( f.font )
  88. {
  89.     textCol = f.textCol;
  90.     fsize = f.fsize;
  91.     chset = f.chset;
  92. }
  93.  
  94. inline const HTMLFont &HTMLFont::operator=( const HTMLFont &f )
  95. {
  96.     font = f.font;
  97.     textCol = f.textCol;
  98.     fsize = f.fsize;
  99.     chset = f.chset;
  100.  
  101.     return *this;
  102. }
  103.  
  104. inline bool HTMLFont::operator==( const HTMLFont &f )
  105. {
  106.     return ( !strcmp( font.family(), f.font.family() ) &&
  107.         font.weight() == f.font.weight() &&
  108.         font.italic() == f.font.italic() &&
  109.         font.underline() == f.font.underline() &&
  110.         font.strikeOut() == f.font.strikeOut() &&
  111.         textCol.red() == f.textCol.red() &&
  112.         textCol.green() == f.textCol.green() &&
  113.         textCol.blue() == f.textCol.blue() &&
  114.         fsize == f.fsize &&
  115.         chset == f.chset );
  116. }
  117.  
  118. //-----------------------------------------------------------------------------
  119.  
  120. class HTMLFontManager
  121. {
  122. public:
  123.     HTMLFontManager();
  124.  
  125.     const HTMLFont *getFont( const HTMLFont &f );
  126.  
  127. private:
  128.     QList<HTMLFont> list;
  129. };
  130.  
  131. //-----------------------------------------------------------------------------
  132.  
  133. #endif    // __HTMLFONT_H__
  134.  
  135.